//
//  ToResiduePayViewController.m
//  HAODE
//
//  Created by panquanReabam.com on 15/9/26.
//  Copyright (c) 2015年 reabam.com. All rights reserved.
//

#import "ToResiduePayViewController.h"
#import "HAODEsingleton.h"
#import "RDVTabBarController.h"
#import "AttributedLabel.h"
#import "UIViewExt.h"
#import "HttpRequest.h"
#import "JSONKit.h"
#import "ServiceListViewController.h"
#import "orderListsViewController.h"
#import "QRCodeGenerator.h"
#import "UIButton+WebCache.h"
@interface ToResiduePayViewController ()<UIScrollViewDelegate,UIGestureRecognizerDelegate>

@end

@implementation ToResiduePayViewController

{
    HAODEsingleton* commdity;
    UILabel*shoukuanfangsi;
    UIButton*xianjinlabelbtn;
    UIButton*shuakabtnlabelbtn;
    UIButton*zhifulabelbaobtn;
    UIButton*weixinbtnlabelbtn;
    UIScrollView*myscrollView;
    UIButton*Btnture;
    NSString *payType;
    AttributedLabel*xuanze;
     UIButton *time;
    UIView*ditu;
    UILabel*wufuhaopayAmount;
    UIImageView*chaimageview;
     UILabel*payAmount;
    UILabel *orderNo;
    UIButton*editor1;
    UIButton* backButton;
    UILabel*titleStr;
}


@synthesize alt = alt;

-(void)BackAction:(UIButton *)sender{
    [time removeFromSuperview];
    if ([commdity.sat isEqualToString:@"shouyin"]) {
  
        orderListsViewController*de = [[orderListsViewController alloc] init];
        
        [self.navigationController pushViewController:de animated:YES];
        
        
    }
    
    if ([commdity.sat isEqualToString:@"bushouyin"]) {
      [self.navigationController popViewControllerAnimated:YES];
    }
    if ([commdity.sat isEqualToString:@"fuwushouyin"]) {
        ServiceListViewController*de = [[ServiceListViewController alloc] init];
        
        [self.navigationController pushViewController:de animated:YES];
    }
    
    if ([commdity.sat isEqualToString:@"fuwubushouyin"]) {
        ServiceListViewController*de = [[ServiceListViewController alloc] init];
        
        [self.navigationController pushViewController:de animated:YES];
    }
    if ([commdity.sat isEqualToString:@"card"]) {
        [self.navigationController popViewControllerAnimated:YES];
    }
    
    
}

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
  
    self.navigationController.navigationBarHidden=YES;
    [[self rdv_tabBarController] setTabBarHidden:YES];
    
    [self.navigationController.navigationBar setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
    self.navigationController.navigationBar.shadowImage = [[UIImage alloc] init];
    self.navigationController.navigationBar.barStyle = UIBaselineAdjustmentNone;
    UILabel *lineLabel=[[UILabel alloc] initWithFrame:CGRectMake(0, 43,ScreenWidth, 0.3)];
    [lineLabel setBackgroundColor:[UIColor colorWithRed:37/255.0 green:60/255.0 blue:1/255.0 alpha:0.3]];
    lineLabel.alpha=0.3;
    [self.navigationController.navigationBar addSubview:lineLabel];

    _narview.backgroundColor=[UIColor colorWithRed:14/255.0 green:23/255.0 blue:0/255.0 alpha:1.0];
    
    [self jiazaititle];
    self.title=@"收银";
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                                     [UIColor blackColor],
                                                                     UITextAttributeTextColor,
                                                                     [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1],
                                                                     UITextAttributeTextShadowColor,
                                                                     [NSValue valueWithUIOffset:UIOffsetMake(0, 0)],
                                                                     UITextAttributeTextShadowOffset,
                                                                     [UIFont fontWithName:@"Helvetica Neue" size:tetlefot],
                                                                     UITextAttributeFont,nil]];

}


-(void)jiazaititle{
    [editor1 removeFromSuperview];
    [backButton removeFromSuperview];
    [titleStr removeFromSuperview];
    
    UIImage* backImage = [UIImage imageNamed:@"fanhui"];
    CGRect backframe = CGRectMake(10,27.5,30,30);
    backButton= [[UIButton alloc] initWithFrame:backframe];
    [backButton setBackgroundImage:backImage forState:UIControlStateNormal];
    [backButton addTarget:self action:@selector(BackAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:backButton];
    
    titleStr=[[UILabel alloc]initWithFrame:CGRectMake(0, 10, ScreenWidth, 64)];
    titleStr.text=@"收银";
    titleStr.textColor=[UIColor whiteColor];
    titleStr.font=[UIFont systemFontOfSize:18];
    titleStr.textAlignment=NSTextAlignmentCenter;
    [self.view addSubview:titleStr];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    
    commdity=[HAODEsingleton shared];
    
    if ([commdity.sat isEqualToString:@"shouyin"]) {
        [self dingdanshouyin];
    }
    
    if ([commdity.sat isEqualToString:@"bushouyin"]) {
        [self dingdanbushouyin];
    }
    if ([commdity.sat isEqualToString:@"fuwushouyin"]) {
        [self fuwushouyin];
    }
    
    if ([commdity.sat isEqualToString:@"fuwubushouyin"]) {
        [self fuwubushouyin];
    }
    
    if ([commdity.sat isEqualToString:@"card"]) {
        [self cardshouyin];
    }
    
}





//储值卡收银
-(void)cardshouyin{
 

    
    orderNo=[[UILabel alloc]initWithFrame:CGRectMake(0, 64, ScreenWidth,40)];
    orderNo.text=[NSString stringWithFormat:@"    订单号 %@ %@",[commdity.Dict objectForKey:@"orderNo"],@"充值金额"];
    orderNo.textColor=luseColor;
    orderNo.backgroundColor=[UIColor colorWithRed:14/255.0 green:23/255.0 blue:0/255.0 alpha:1.0];
    orderNo.font=[UIFont boldSystemFontOfSize:14];
    [self.view addSubview:orderNo];
    UILabel*line=[[UILabel alloc]initWithFrame:CGRectMake(0, 64, ScreenWidth,0.35)];
    line.backgroundColor=luseColor;
    [self.view addSubview:line];

    commdity.orderId=[commdity.Dict objectForKey:@"orderId"];
    commdity.orderType=@"card";
    commdity.how=[NSString stringWithFormat:@"%@",[commdity.Dict objectForKey:@"payAmount"]];
    NSString*GoldPrice=[NSString stringWithFormat:@"%@",[commdity.Dict objectForKey:@"payAmount"]];
    NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
    [numberFormatter setPositiveFormat:@"###,##0.00;"];
    NSString *formattedNumberString = [numberFormatter stringFromNumber:[NSNumber numberWithDouble:GoldPrice.floatValue]];
    [self jiazai:formattedNumberString];
    
}


//服务收银
-(void)fuwushouyin{
    self.title=@"收银";
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                                     [UIColor whiteColor],
                                                                     UITextAttributeTextColor,
                                                                     [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1],
                                                                     UITextAttributeTextShadowColor,
                                                                     [NSValue valueWithUIOffset:UIOffsetMake(0, 0)],
                                                                     UITextAttributeTextShadowOffset,
                                                                     [UIFont fontWithName:@"Helvetica Neue" size:tetlefot],
                                                                     UITextAttributeFont,nil]];
    
    
    
    
    
    
    
    
    
    
    
   
    
    orderNo=[[UILabel alloc]initWithFrame:CGRectMake(0, 64, ScreenWidth,40)];
    orderNo.text=[NSString stringWithFormat:@"    订单号 %@ %@", commdity.noId,@"服务金额"];
    orderNo.textColor=luseColor;
    orderNo.backgroundColor=[UIColor colorWithRed:14/255.0 green:23/255.0 blue:0/255.0 alpha:1.0];
    orderNo.font=[UIFont boldSystemFontOfSize:14];
    [self.view addSubview:orderNo];
    UILabel*line=[[UILabel alloc]initWithFrame:CGRectMake(0, 64, ScreenWidth,0.35)];
    line.backgroundColor=luseColor;
    [self.view addSubview:line];
    commdity. orderId=commdity. orderId;
    commdity.orderType=@"service";
    NSString*GoldPrice=[NSString stringWithFormat:@"%@",commdity.how];
    NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
    [numberFormatter setPositiveFormat:@"###,##0.00;"];
    NSString *formattedNumberString = [numberFormatter stringFromNumber:[NSNumber numberWithDouble:GoldPrice.floatValue]];
    
    
       [self jiazai:formattedNumberString];
    
}
//商品直接下订单收银
-(void)dingdanshouyin{
    self.title=@"收银";
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                                     [UIColor whiteColor],
                                                                     UITextAttributeTextColor,
                                                                     [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1],
                                                                     UITextAttributeTextShadowColor,
                                                                     [NSValue valueWithUIOffset:UIOffsetMake(0, 0)],
                                                                     UITextAttributeTextShadowOffset,
                                                                     [UIFont fontWithName:@"Helvetica Neue" size:tetlefot],
                                                                     UITextAttributeFont,nil]];
    
    
    
    
    
    
    
    
    commdity.orderId=[commdity.Dict objectForKey:@"orderId"] ;
    commdity.orderType=@"order";
    NSLog(@"-------%@",commdity.Dict);
    
    
    orderNo=[[UILabel alloc]initWithFrame:CGRectMake(0,64, ScreenWidth,40)];
    orderNo.textColor=luseColor;
    orderNo.backgroundColor=[UIColor colorWithRed:14/255.0 green:23/255.0 blue:0/255.0 alpha:1.0];
    orderNo.font=[UIFont boldSystemFontOfSize:14];
    [self.view addSubview:orderNo];
    UILabel*line=[[UILabel alloc]initWithFrame:CGRectMake(0, 64, ScreenWidth,0.35)];
    line.backgroundColor=luseColor;
    [self.view addSubview:line];

    if ([[commdity.Dict objectForKey:@"gatheringType"]isEqualToString:@"E"]) {
        NSString *sat=@"收定金";
        orderNo.text=[NSString stringWithFormat:@"    订单号 %@ %@", [commdity.Dict objectForKey:@"orderNo"],sat];

    }
    if ([[commdity.Dict objectForKey:@"gatheringType"]isEqualToString:@"F"]) {
        NSString *sat=@"收全款";
        orderNo.text=[NSString stringWithFormat:@"    订单号 %@ %@", [commdity.Dict objectForKey:@"orderNo"],sat];
        
    }
    if ([[commdity.Dict objectForKey:@"gatheringType"]isEqualToString:@"R"]) {
        NSString *sat=@"收尾款";
        orderNo.text=[NSString stringWithFormat:@"    订单号 %@ %@", [commdity.Dict objectForKey:@"orderNo"],sat];
        
    }
 
    commdity.how=[NSString stringWithFormat:@"%@",[commdity.Dict objectForKey:@"payAmount"]];
    NSString*GoldPrice=[NSString stringWithFormat:@"%@",[commdity.Dict objectForKey:@"payAmount"]];
    NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
    [numberFormatter setPositiveFormat:@"###,##0.00;"];
    NSString *formattedNumberString = [numberFormatter stringFromNumber:[NSNumber numberWithDouble:GoldPrice.floatValue]];
    
    [self jiazai:formattedNumberString];
    
}

- (void)xianjinlabelbtn:(UIButton *)button{

    shoukuanfangsi.textColor=[UIColor clearColor];
    payType=@"C";
      [xianjinlabelbtn setTitleColor:shenluse forState:UIControlStateNormal];
      [shuakabtnlabelbtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
      [zhifulabelbaobtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
      [weixinbtnlabelbtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
      [self add];
    
}
- (void)shuakabtnlabelbtn:(UIButton *)button{
    shoukuanfangsi.textColor=[UIColor clearColor];
    payType=@"B";
    [xianjinlabelbtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [shuakabtnlabelbtn setTitleColor:shenluse forState:UIControlStateNormal];
    [zhifulabelbaobtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [weixinbtnlabelbtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [self add];
    
    
}
- (void)zhifubaobtn:(UIButton *)button{
 
    
    [myscrollView removeFromSuperview];
    shoukuanfangsi.textColor=[UIColor clearColor];
    [xianjinlabelbtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [shuakabtnlabelbtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [zhifulabelbaobtn setTitleColor:shenluse forState:UIControlStateNormal];
    [weixinbtnlabelbtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [myscrollView removeFromSuperview];
    [chaimageview removeFromSuperview];
    ditu=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight+40)];
    ditu.backgroundColor=backColor;
    ditu.alpha=0.6;
    [self.view addSubview:ditu];
    //  手势
    
    UITapGestureRecognizer *singleFingerOne = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(closeKeyBoad)];
    singleFingerOne.numberOfTouchesRequired = 1; //手指数
    singleFingerOne.numberOfTapsRequired = 1; //tap次数
    singleFingerOne.delegate = self;
    [ditu addGestureRecognizer:singleFingerOne];

    
    myscrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0,payAmount.bottom, ScreenWidth, ScreenWidth)];
     [myscrollView setBackgroundColor: [UIColor whiteColor]];
    
    myscrollView.delegate = self;
    myscrollView.userInteractionEnabled = YES;
    myscrollView.scrollEnabled = YES;
    myscrollView.showsVerticalScrollIndicator = FALSE;
    myscrollView.showsHorizontalScrollIndicator = FALSE;
    [self.view addSubview:myscrollView];
    
    
    
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    NSString* Token = [user objectForKey:@"tokenId"];
    NSMutableDictionary *params = [NSMutableDictionary new];
    [params setValue:Token forKey:@"tokenId"];
    [params setValue:commdity.orderType forKey:@"orderType"];
    [params setValue:commdity.orderId  forKey:@"orderId"];
    [params setValue:[NSString stringWithFormat:@"%.2f",  [commdity.how doubleValue]] forKey:@"payAmount"];
    
    [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
    NSLog(@"--------%@",params);
    
    [HttpRequest requestData:@"Business/Pay/AliQrPay" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
        if (isSuccess) {
            
            NSLog(@"%@",severDataDict.dataDict);
            if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                
                [Global hideProgressHUDInternal:self.view];
                  commdity.gid=[severDataDict.dataDict objectForKey:@"gid"];
                
                [self times];
                NSString*s=@"支付宝支付";
                
                [self str:s priceStr:payAmount.text QRStr:[severDataDict.dataDict  objectForKey:@"qrCode"]];

                
                
                
            }else{
                [Global hideProgressHUDInternal:self.view];
                NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                [Global showTextHudSub:requestResultStr view:self.view];
            }
            
        }
        else
        {
            [Global hideProgressHUDInternal:self.view];
            NSLog(@"aaaaaaaa%@",severDataDict.dataDict);
            [Global showTextHudSub:@"连接失败" view:self.view];
        }
        
    }];
    chaimageview=[[UIImageView alloc]initWithFrame:CGRectMake(ScreenWidth-50, payAmount.bottom-15, 30, 30)];
    chaimageview .image=[UIImage imageNamed:@"chas"];
    //    [chaimageview addGestureRecognizer:singleFingerOne];
    [self.view addSubview:chaimageview];
}
//微信支付
- (void)weixinbtn:(UIButton *)button{
    
     [myscrollView removeFromSuperview];
   shoukuanfangsi.textColor=[UIColor clearColor];
    [xianjinlabelbtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [shuakabtnlabelbtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [zhifulabelbaobtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [weixinbtnlabelbtn setTitleColor:shenluse forState:UIControlStateNormal];
 
  
    [chaimageview removeFromSuperview];
    ditu=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight+40)];
    ditu.backgroundColor=backColor;
    ditu.alpha=0.6;
    [self.view addSubview:ditu];
    //  手势
    
    UITapGestureRecognizer *singleFingerOne = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(closeKeyBoad)];
    singleFingerOne.numberOfTouchesRequired = 1; //手指数
    singleFingerOne.numberOfTapsRequired = 1; //tap次数
    singleFingerOne.delegate = self;
    [ditu addGestureRecognizer:singleFingerOne];

    myscrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0,payAmount.bottom, ScreenWidth, ScreenWidth)];
    [myscrollView setBackgroundColor: [UIColor whiteColor]];
    
    myscrollView.delegate = self;
    myscrollView.userInteractionEnabled = YES;
    myscrollView.scrollEnabled = YES;
    myscrollView.showsVerticalScrollIndicator = FALSE;
    myscrollView.showsHorizontalScrollIndicator = FALSE;
    [self.view addSubview:myscrollView];

    
    
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    NSString* Token = [user objectForKey:@"tokenId"];
    NSMutableDictionary *params = [NSMutableDictionary new];
    [params setValue:Token forKey:@"tokenId"];
    [params setValue:commdity.orderType forKey:@"orderType"];
    [params setValue:commdity.orderId  forKey:@"orderId"];
    [params setValue:[NSString stringWithFormat:@"%.2f",  [commdity.how doubleValue]] forKey:@"payAmount"];

    [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
    NSLog(@"--------%@",params);
    
    [HttpRequest requestData:@"Business/Pay/WxScanPay" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
        if (isSuccess) {
            
                 NSLog(@"%@",severDataDict.dataDict);
        if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
            
            [Global hideProgressHUDInternal:self.view];
            commdity.gid=[severDataDict.dataDict objectForKey:@"gid"];
                
          [self times];
            NSString*s=@"微信支付";
            [self str:s priceStr:payAmount.text QRStr:[severDataDict.dataDict  objectForKey:@"qrCode"]];

    

                
            }else{
                [Global hideProgressHUDInternal:self.view];
                NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                [Global showTextHudSub:requestResultStr view:self.view];
            }
            
        }
        else
        {
            [Global hideProgressHUDInternal:self.view];
            NSLog(@"aaaaaaaa%@",severDataDict.dataDict);
            [Global showTextHudSub:@"连接失败" view:self.view];
        }
        
    }];
    
    
    chaimageview=[[UIImageView alloc]initWithFrame:CGRectMake(ScreenWidth-50, payAmount.bottom-15, 30, 30)];
    chaimageview .image=[UIImage imageNamed:@"chas"];
    //    [chaimageview addGestureRecognizer:singleFingerOne];
    [self.view addSubview:chaimageview];
}
//现金支付//刷卡支付

-(void)str:(NSString*)strs priceStr:(NSString*)priceStr QRStr:(NSString*)QRStr{
    
    NSString *s12 = [NSString stringWithFormat:@"%@",  @"你选择"];
    UIFont *font12 = [UIFont systemFontOfSize:15];
    CGSize size12 = CGSizeMake(320, 2000);
    CGSize labelsize12 = [s12 sizeWithFont:font12 constrainedToSize:size12 lineBreakMode:NSLineBreakByCharWrapping];
    
    
    UILabel*label1=[[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth/2-100, 27, labelsize12.width, 15)];
    label1.text=[NSString stringWithFormat:@"%@",@"你选择"];
    label1.textColor=[UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1];
    label1.font=[UIFont systemFontOfSize:15];
    [myscrollView addSubview:label1];
    
    NSString *s1 = [NSString stringWithFormat:@"%@",  strs];
    UIFont *font1= [UIFont systemFontOfSize:15];
    CGSize size1= CGSizeMake(320, 2000);
    CGSize labelsize1= [s1 sizeWithFont:font1 constrainedToSize:size1 lineBreakMode:NSLineBreakByCharWrapping];
    UILabel*label2=[[UILabel alloc]initWithFrame:CGRectMake(label1.right+5, 27, labelsize1.width+10, 15)];
    label2.text=[NSString stringWithFormat:@"%@",strs];
    label2.backgroundColor=[UIColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:1];
    label2.textColor=[UIColor whiteColor];
    label2.textAlignment=NSTextAlignmentCenter;
    label2.font=[UIFont systemFontOfSize:14];
    [myscrollView addSubview:label2];
    
    UILabel*label3=[[UILabel alloc]initWithFrame:CGRectMake(label2.right+5, 27, 100, 15)];
    label3.text=[NSString stringWithFormat:@"%@",@"需付金额:"];
    label3.textColor=[UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1];
    label3.font=[UIFont systemFontOfSize:15];
    [myscrollView addSubview:label3];
    
    
    
    UILabel*payAmounts=[[UILabel alloc]initWithFrame:CGRectMake(0, label1.bottom+7.5, ScreenWidth, 24)];
    payAmounts.text=[NSString stringWithFormat:@"%@",payAmount.text];
    payAmounts.textColor=[UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1];
    payAmounts.textAlignment=NSTextAlignmentCenter;
    payAmounts.font=[UIFont systemFontOfSize:24];

    
    NSMutableAttributedString *AttributedStr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@",payAmount.text]];
    
    [AttributedStr addAttribute:NSFontAttributeName
     
                          value:[UIFont systemFontOfSize:14]
     
                          range:NSMakeRange(0, 1)];
    
    [AttributedStr addAttribute:NSForegroundColorAttributeName
     
                          value:[UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1]
     
                          range:NSMakeRange(0, 1)];
    payAmounts.attributedText = AttributedStr;
    
    [myscrollView addSubview:payAmounts];
    
    
    Btnture = [[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth/2-75, payAmounts.bottom+132/2, 150, 150)];
    [Btnture setImageWithURL:[NSURL URLWithString:QRStr]];
    Btnture.contentMode = UIViewContentModeScaleAspectFit;
    [myscrollView addSubview:Btnture];
    
    
    [myscrollView setContentSize:CGSizeMake(ScreenWidth, Btnture.bottom+60)];
    
}


-(void)add{
    
    
    [myscrollView removeFromSuperview];
    [chaimageview removeFromSuperview];
    ditu=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight+40)];
    ditu.backgroundColor=backColor;
    ditu.alpha=0.6;
    [self.view addSubview:ditu];
    //  手势
    
    UITapGestureRecognizer *singleFingerOne = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(closeKeyBoad)];
    singleFingerOne.numberOfTouchesRequired = 1; //手指数
    singleFingerOne.numberOfTapsRequired = 1; //tap次数
    singleFingerOne.delegate = self;
    [ditu addGestureRecognizer:singleFingerOne];
    
    
    myscrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0,payAmount.bottom-0.5, ScreenWidth, ScreenWidth)];
    [myscrollView setBackgroundColor: [UIColor whiteColor]];
    
    myscrollView.delegate = self;
    myscrollView.userInteractionEnabled = YES;
    myscrollView.scrollEnabled = YES;
    myscrollView.showsVerticalScrollIndicator = FALSE;
    myscrollView.showsHorizontalScrollIndicator = FALSE;
    [self.view addSubview:myscrollView];
    if ([payType isEqualToString:@"C"]) {
        NSString*strs=@"现金支付";
        
        NSString *s12 = [NSString stringWithFormat:@"%@",  @"你选择"];
        UIFont *font12 = [UIFont systemFontOfSize:15];
        CGSize size12 = CGSizeMake(320, 2000);
        CGSize labelsize12 = [s12 sizeWithFont:font12 constrainedToSize:size12 lineBreakMode:NSLineBreakByCharWrapping];
        
        
        UILabel*label1=[[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth/2-100, height5or6, labelsize12.width, 15)];
        label1.text=[NSString stringWithFormat:@"%@",@"你选择"];
        label1.textColor=[UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1];
        label1.font=[UIFont systemFontOfSize:15];
        [myscrollView addSubview:label1];
        
        NSString *s1 = [NSString stringWithFormat:@"%@",  strs];
        UIFont *font1= [UIFont systemFontOfSize:15];
        CGSize size1= CGSizeMake(320, 2000);
        CGSize labelsize1= [s1 sizeWithFont:font1 constrainedToSize:size1 lineBreakMode:NSLineBreakByCharWrapping];
        UILabel*label2=[[UILabel alloc]initWithFrame:CGRectMake(label1.right+5, height5or6, labelsize1.width+10, 15)];
        label2.text=[NSString stringWithFormat:@"%@",strs];
        label2.backgroundColor=[UIColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:1];
        label2.textColor=[UIColor whiteColor];
        label2.textAlignment=NSTextAlignmentCenter;
        label2.font=[UIFont systemFontOfSize:14];
        [myscrollView addSubview:label2];
        UILabel*label3=[[UILabel alloc]initWithFrame:CGRectMake(label2.right+5, height5or6, 100, 15)];
        label3.text=[NSString stringWithFormat:@"%@",@"需付金额:"];
        label3.textColor=[UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1];
        label3.font=[UIFont systemFontOfSize:15];
        [myscrollView addSubview:label3];
        
        
        UILabel*payAmounts=[[UILabel alloc]initWithFrame:CGRectMake(0, label1.bottom+7.5, ScreenWidth, 24)];
        payAmounts.text=[NSString stringWithFormat:@"%@",payAmount.text];
        payAmounts.textColor=[UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1];
        payAmounts.textAlignment=NSTextAlignmentCenter;
        payAmounts.font=[UIFont systemFontOfSize:24];
        
        NSMutableAttributedString *AttributedStr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@",payAmount.text]];
        
        [AttributedStr addAttribute:NSFontAttributeName
         
                              value:[UIFont systemFontOfSize:14]
         
                              range:NSMakeRange(0, 1)];
        
        [AttributedStr addAttribute:NSForegroundColorAttributeName
         
                              value:[UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1]
         
                              range:NSMakeRange(0, 1)];
        payAmounts.attributedText = AttributedStr;
        
        [myscrollView addSubview:payAmounts];
        Btnture = [[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth/2-50, payAmounts.bottom+80, 215/2,  215/2)];
        Btnture.layer.masksToBounds = YES;
        Btnture.backgroundColor= luseColor;
        Btnture.layer.cornerRadius =  215/2/2;
        [Btnture setTitle:@"确认" forState:UIControlStateNormal];
        [Btnture setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [Btnture addTarget:self action:@selector(ture:) forControlEvents:UIControlEventTouchUpInside];
        Btnture.layer.borderColor = [UIColor whiteColor].CGColor;
        Btnture.layer.borderWidth = 0;
        Btnture.contentMode = UIViewContentModeScaleAspectFit;
        Btnture.titleLabel.font=[UIFont systemFontOfSize:18];
        [myscrollView addSubview:Btnture];
        
    }
    if ([payType isEqualToString:@"B"]) {
            NSString*strs=@"刷卡支付";
        
        NSString *s12 = [NSString stringWithFormat:@"%@",  @"你选择"];
        UIFont *font12 = [UIFont systemFontOfSize:15];
        CGSize size12 = CGSizeMake(320, 2000);
        CGSize labelsize12 = [s12 sizeWithFont:font12 constrainedToSize:size12 lineBreakMode:NSLineBreakByCharWrapping];
        
        
        UILabel*label1=[[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth/2-100, height5or6, labelsize12.width, 15)];
        label1.text=[NSString stringWithFormat:@"%@",@"你选择"];
        label1.textColor=[UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1];
        label1.font=[UIFont systemFontOfSize:15];
        [myscrollView addSubview:label1];
        
        NSString *s1 = [NSString stringWithFormat:@"%@",  strs];
        UIFont *font1= [UIFont systemFontOfSize:15];
        CGSize size1= CGSizeMake(320, 2000);
        CGSize labelsize1= [s1 sizeWithFont:font1 constrainedToSize:size1 lineBreakMode:NSLineBreakByCharWrapping];
        UILabel*label2=[[UILabel alloc]initWithFrame:CGRectMake(label1.right+5, height5or6, labelsize1.width+10, 15)];
        label2.text=[NSString stringWithFormat:@"%@",strs];
        label2.backgroundColor=[UIColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:1];
        label2.textColor=[UIColor whiteColor];
        label2.textAlignment=NSTextAlignmentCenter;
        label2.font=[UIFont systemFontOfSize:14];
        [myscrollView addSubview:label2];
        UILabel*label3=[[UILabel alloc]initWithFrame:CGRectMake(label2.right+5, height5or6, 100, 15)];
        label3.text=[NSString stringWithFormat:@"%@",@"需付金额:"];
        label3.textColor=[UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1];
        label3.font=[UIFont systemFontOfSize:15];
        [myscrollView addSubview:label3];
        
        
        UILabel*payAmounts=[[UILabel alloc]initWithFrame:CGRectMake(0, label1.bottom+7.5, ScreenWidth, 24)];
        payAmounts.text=[NSString stringWithFormat:@"%@",payAmount.text];
        payAmounts.textColor=[UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1];
        payAmounts.textAlignment=NSTextAlignmentCenter;
        payAmounts.font=[UIFont systemFontOfSize:24];
        
        NSMutableAttributedString *AttributedStr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@",payAmount.text]];
        
        [AttributedStr addAttribute:NSFontAttributeName
         
                              value:[UIFont systemFontOfSize:14]
         
                              range:NSMakeRange(0, 1)];
        
        [AttributedStr addAttribute:NSForegroundColorAttributeName
         
                              value:[UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1]
         
                              range:NSMakeRange(0, 1)];
        payAmounts.attributedText = AttributedStr;
        
        [myscrollView addSubview:payAmounts];
        Btnture = [[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth/2-50, payAmounts.bottom+80, 215/2,  215/2)];
        Btnture.layer.masksToBounds = YES;
        Btnture.backgroundColor= luseColor;
        Btnture.layer.cornerRadius =  215/2/2;
        [Btnture setTitle:@"确认" forState:UIControlStateNormal];
        [Btnture setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [Btnture addTarget:self action:@selector(ture:) forControlEvents:UIControlEventTouchUpInside];
        Btnture.layer.borderColor = [UIColor whiteColor].CGColor;
        Btnture.layer.borderWidth = 0;
        Btnture.contentMode = UIViewContentModeScaleAspectFit;
        Btnture.titleLabel.font=[UIFont systemFontOfSize:18];
        [myscrollView addSubview:Btnture];
    }

    
    
    [myscrollView setContentSize:CGSizeMake(ScreenWidth, Btnture.bottom+60)];
    
    chaimageview=[[UIImageView alloc]initWithFrame:CGRectMake(ScreenWidth-50, payAmount.bottom-15, 30, 30)];
    chaimageview .image=[UIImage imageNamed:@"chas"];
    //    [chaimageview addGestureRecognizer:singleFingerOne];
    [self.view addSubview:chaimageview];

    
    
}
//直接收银
- (void)ture:(UIButton *)button{
//服务收银
  
    if ([commdity.sat isEqualToString:@"fuwushouyin"]) {
        if ([payType length] <1)
        {
            [self showAlertMessage:@"请选择支付方式"];
        }
        else{
            
            NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
            NSString* Token = [user objectForKey:@"tokenId"];
            if (Token ==nil) {
                Token=@"dd";
            }
            
            NSMutableDictionary *params = [NSMutableDictionary new];
            [params setValue:Token forKey:@"tokenId"];
            [params setValue:commdity.orderId forKey:@"orderId"];
            [params setValue:@"service" forKey:@"orderType"];
            [params setValue:[NSString stringWithFormat:@"%.2f",  [commdity.how doubleValue]] forKey:@"payAmount"];
            [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:20 view:self.view];
            
            
            [HttpRequest requestData:@"Business/Pay/CashPay" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
                if (isSuccess) {
                    NSLog(@"33333333====%@",severDataDict.dataDict);
                    if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                        [Global hideProgressHUDInternal:self.view];
                        
                        commdity.tuichu=@"shouye";
                        ServiceListViewController*de = [[ServiceListViewController alloc] init];
                        
                        [self.navigationController pushViewController:de animated:YES];
                    }else{
                        [Global hideProgressHUDInternal:self.view];
                        NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                        // [Global showTextHud:requestResultStr view:self.view];
                        [Global showTextHudSub:requestResultStr view:self.view];
                    }
                    
                }
                else
                {
                    [Global hideProgressHUDInternal:self.view];
                    
                    [Global showTextHudSub:@"连接失败" view:self.view];
                }
                
            }];
            
        }

    }
    
    
    if ([commdity.sat isEqualToString:@"fuwubushouyin"]) {
        if ([payType length] <1)
        {
            [self showAlertMessage:@"请选择支付方式"];
        }
        else{
            
            NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
            NSString* Token = [user objectForKey:@"tokenId"];
            if (Token ==nil) {
                Token=@"dd";
            }
          

            NSMutableDictionary *params = [NSMutableDictionary new];
            [params setValue:Token forKey:@"tokenId"];
            [params setValue:commdity.orderId forKey:@"orderId"];
            [params setValue:@"service" forKey:@"orderType"];
            [params setValue:[NSString stringWithFormat:@"%.2f",  [[commdity.Dict objectForKey:@"payAmount"] doubleValue]] forKey:@"payAmount"];
            [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:20 view:self.view];
            
            
            [HttpRequest requestData:@"Business/Pay/CashPay" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
                if (isSuccess) {
                    NSLog(@"33333333====%@",severDataDict.dataDict);
                    if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                        [Global hideProgressHUDInternal:self.view];
                        
                        commdity.tuichu=@"自动不用做";
                        [self.navigationController popViewControllerAnimated:YES];

                        
                    }else{
                        [Global hideProgressHUDInternal:self.view];
                        NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                        // [Global showTextHud:requestResultStr view:self.view];
                        [Global showTextHudSub:requestResultStr view:self.view];
                    }
                    
                }
                else
                {
                    [Global hideProgressHUDInternal:self.view];
                    
                    [Global showTextHudSub:@"连接失败" view:self.view];
                }
                
            }];
            
        }
        
    }

    
    
    
//22222222订单收银
    
    
    if ([commdity.sat isEqualToString:@"shouyin"]) {
   
            if ([payType length] <1)
            {
                [self showAlertMessage:@"请选择支付方式"];
            }
            else{
    
                NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
                NSString* Token = [user objectForKey:@"tokenId"];
                if (Token ==nil) {
                    Token=@"dd";
                }
    
                NSMutableDictionary *params = [NSMutableDictionary new];
                [params setValue:Token forKey:@"tokenId"];
                [params setValue:[commdity.Dict objectForKey:@"orderId"] forKey:@"orderId"];
                [params setValue:@"order" forKey:@"orderType"];
                [params setValue:[NSString stringWithFormat:@"%.2f",  [[commdity.Dict objectForKey:@"payAmount"]doubleValue]] forKey:@"payAmount"];
                [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:20 view:self.view];
    
    
                [HttpRequest requestData:@"Business/Pay/CashPay" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
                    if (isSuccess) {    NSLog(@"33333333====%@",severDataDict.dataDict);
                        if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                            [Global hideProgressHUDInternal:self.view];
    
                            commdity.tuichu=@"shouye";
                            commdity.filterNPay=@"N";
                            
                            commdity.filterType=@"order";
                            orderListsViewController*de = [[orderListsViewController alloc] init];
                            
                            [self.navigationController pushViewController:de animated:YES];
                        }else{
                            [Global hideProgressHUDInternal:self.view];
                            NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                            // [Global showTextHud:requestResultStr view:self.view];
                            [Global showTextHudSub:requestResultStr view:self.view];
                        }
    
                    }
                    else
                    {
                        [Global hideProgressHUDInternal:self.view];
                        
                        [Global showTextHudSub:@"连接失败" view:self.view];
                    }
                    
                }];
                
            }
    
    }
   
    
    
    
    
    
    if ([commdity.sat isEqualToString:@"bushouyin"]) {
        
        if ([payType length] <1)
        {
            [self showAlertMessage:@"请选择支付方式"];
        }
        else{
            
            NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
            NSString* Token = [user objectForKey:@"tokenId"];
            if (Token ==nil) {
                Token=@"dd";
            }
            
            NSMutableDictionary *params = [NSMutableDictionary new];
            [params setValue:Token forKey:@"tokenId"];
            [params setValue:[commdity.Dict objectForKey:@"orderId"] forKey:@"orderId"];
            [params setValue:@"order" forKey:@"orderType"];
            [params setValue:[NSString stringWithFormat:@"%.2f",  [[commdity.Dict objectForKey:@"payAmount"]doubleValue]] forKey:@"payAmount"];
            [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:20 view:self.view];
            
            
            [HttpRequest requestData:@"Business/Pay/CashPay" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
                if (isSuccess) {    NSLog(@"33333333====%@",severDataDict.dataDict);
                    if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                        [Global hideProgressHUDInternal:self.view];
                          commdity.tuichu=@"自动不用做";
                         [self.navigationController popViewControllerAnimated:YES];
                        
                    }else{
                        [Global hideProgressHUDInternal:self.view];
                        NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                        // [Global showTextHud:requestResultStr view:self.view];
                        [Global showTextHudSub:requestResultStr view:self.view];
                    }
                    
                }
                else
                {
                    [Global hideProgressHUDInternal:self.view];
                    
                    [Global showTextHudSub:@"连接失败" view:self.view];
                }
                
            }];
            
        }
        
        
        
        
    }

    
    
    
    
  
    
    
    if ([commdity.sat isEqualToString:@"card"]) {
        
        if ([payType length] <1)
        {
            [self showAlertMessage:@"请选择支付方式"];
        }
        else{
            
            NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
            NSString* Token = [user objectForKey:@"tokenId"];
            if (Token ==nil) {
                Token=@"dd";
            }
            
            NSMutableDictionary *params = [NSMutableDictionary new];
            [params setValue:Token forKey:@"tokenId"];
            [params setValue:[commdity.Dict objectForKey:@"orderId"] forKey:@"orderId"];
            [params setValue:@"card" forKey:@"orderType"];
            [params setValue:[NSString stringWithFormat:@"%.2f",  [[commdity.Dict objectForKey:@"payAmount"]doubleValue]] forKey:@"payAmount"];
            [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:20 view:self.view];
            
            
            [HttpRequest requestData:@"Business/Pay/CashPay" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
                if (isSuccess) {    NSLog(@"33333333====%@",severDataDict.dataDict);
                    if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                        [Global hideProgressHUDInternal:self.view];
                        commdity.gengxin=@"";
                         [self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:2] animated:YES];
                    
                    }else{
                        [Global hideProgressHUDInternal:self.view];
                        NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                        // [Global showTextHud:requestResultStr view:self.view];
                        [Global showTextHudSub:requestResultStr view:self.view];
                    }
                    
                }
                else
                {
                    [Global hideProgressHUDInternal:self.view];
                    
                    [Global showTextHudSub:@"连接失败" view:self.view];
                }
                
            }];
            
        }
        
        
        
        
    }

    
    
   [time removeFromSuperview];
    
    
}












//服务补收


-(void)fuwubushouyin{
    self.title=@"补收银";
    commdity.orderType=@"service";
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                                     [UIColor whiteColor],
                                                                     UITextAttributeTextColor,
                                                                     [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1],
                                                                     UITextAttributeTextShadowColor,
                                                                     [NSValue valueWithUIOffset:UIOffsetMake(0, 0)],
                                                                     UITextAttributeTextShadowOffset,
                                                                     [UIFont fontWithName:@"Helvetica Neue" size:tetlefot],
                                                                     UITextAttributeFont,nil]];
    
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    NSString* Token = [user objectForKey:@"tokenId"];
    if (Token ==nil) {
        Token=@"dd";
    }
    
    NSMutableDictionary *params = [NSMutableDictionary new];
    [params setValue:Token forKey:@"tokenId"];
    [params setValue:commdity.orderId forKey:@"serviceId"];
    
    
    
    [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
    
    
    [HttpRequest requestData:@"Business/Service/ToPay" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
        if (isSuccess) {
            NSLog(@"33333333====%@",severDataDict.dataDict);
            if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                [Global hideProgressHUDInternal:self.view];
                
                [Global hideProgressHUDInternal:self.view];
                
                commdity.userName=nil,commdity.Phone=nil;
                
                commdity.Dict=severDataDict.dataDict;
                

                commdity.orderId=[NSString stringWithFormat:@"%@",[commdity.Dict objectForKey:@"serviceId"]];
              
                
                
                orderNo=[[UILabel alloc]initWithFrame:CGRectMake(0, 64, ScreenWidth,40)];
                orderNo.textColor=luseColor;
                orderNo.backgroundColor=[UIColor colorWithRed:14/255.0 green:23/255.0 blue:0/255.0 alpha:1.0];
                orderNo.font=[UIFont boldSystemFontOfSize:14];
                [self.view addSubview:orderNo];
                
                UILabel*line=[[UILabel alloc]initWithFrame:CGRectMake(0, 64, ScreenWidth,0.35)];
                line.backgroundColor=luseColor;
                [self.view addSubview:line];

                orderNo.text=[NSString stringWithFormat:@"    订单号 %@ %@", [commdity.Dict objectForKey:@"serviceNo"],@"服务金额"];
                
                
                 commdity.how=[NSString stringWithFormat:@"%@",[commdity.Dict objectForKey:@"payAmount"]];
                NSString*GoldPrice=[NSString stringWithFormat:@"%@",[commdity.Dict objectForKey:@"payAmount"]];

                NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
                [numberFormatter setPositiveFormat:@"###,##0.00;"];
                NSString *formattedNumberString = [numberFormatter stringFromNumber:[NSNumber numberWithDouble:GoldPrice.floatValue]];
                [self jiazai:formattedNumberString];
                
                
                
                
                
                
                
            }else{
                [Global hideProgressHUDInternal:self.view];
                NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                // [Global showTextHud:requestResultStr view:self.view];
                [Global showTextHudSub:requestResultStr view:self.view];
            }
            
        }
        else
        {
            [Global hideProgressHUDInternal:self.view];
            
            [Global showTextHudSub:@"连接失败" view:self.view];
        }
        
    }];
    
    
    
}



//订单补收


-(void)dingdanbushouyin{
    self.title=@"补收银";
    commdity.orderType=@"order";
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                                     [UIColor whiteColor],
                                                                     UITextAttributeTextColor,
                                                                     [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1],
                                                                     UITextAttributeTextShadowColor,
                                                                     [NSValue valueWithUIOffset:UIOffsetMake(0, 0)],
                                                                     UITextAttributeTextShadowOffset,
                                                                     [UIFont fontWithName:@"Helvetica Neue" size:tetlefot],
                                                                     UITextAttributeFont,nil]];

    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    NSString* Token = [user objectForKey:@"tokenId"];
    if (Token ==nil) {
        Token=@"dd";
    }
    
    NSMutableDictionary *params = [NSMutableDictionary new];
    [params setValue:Token forKey:@"tokenId"];
    [params setValue:commdity.orderId forKey:@"orderId"];
    
    
    
    [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
    
    
    [HttpRequest requestData:@"Business/Order/ToResiduePay" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
        if (isSuccess) {
            NSLog(@"33333333====%@",severDataDict.dataDict);
            if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                [Global hideProgressHUDInternal:self.view];
                
                [Global hideProgressHUDInternal:self.view];

                commdity.userName=nil,commdity.Phone=nil;
                
                commdity.Dict=severDataDict.dataDict;
                
             
                orderNo=[[UILabel alloc]initWithFrame:CGRectMake(0, 64, ScreenWidth,40)];
                orderNo.textColor=luseColor;
                orderNo.backgroundColor=[UIColor colorWithRed:14/255.0 green:23/255.0 blue:0/255.0 alpha:1.0];
                orderNo.font=[UIFont boldSystemFontOfSize:14];
                [self.view addSubview:orderNo];
                
                UILabel*line=[[UILabel alloc]initWithFrame:CGRectMake(0, 64, ScreenWidth,0.35)];
                line.backgroundColor=luseColor;
                [self.view addSubview:line];

                if ([[commdity.Dict objectForKey:@"gatheringType"]isEqualToString:@"E"]) {
                    NSString *sat=@"收定金";
                    orderNo.text=[NSString stringWithFormat:@"    订单号 %@ %@", [commdity.Dict objectForKey:@"orderNo"],sat];
                    
                }
                if ([[commdity.Dict objectForKey:@"gatheringType"]isEqualToString:@"F"]) {
                    NSString *sat=@"收全款";
                    orderNo.text=[NSString stringWithFormat:@"    订单号 %@ %@", [commdity.Dict objectForKey:@"orderNo"],sat];
                    
                }
                if ([[commdity.Dict objectForKey:@"gatheringType"]isEqualToString:@"R"]) {
                    NSString *sat=@"收尾款";
                    orderNo.text=[NSString stringWithFormat:@"    订单号 %@ 已收定金¥ %@ %@", [commdity.Dict objectForKey:@"orderNo"], [commdity.Dict objectForKey:@"earnestMoney"],sat];
                    orderNo.font=[UIFont boldSystemFontOfSize:14];
                }
              
                NSString*GoldPrice=[NSString stringWithFormat:@"%@",[commdity.Dict objectForKey:@"payAmount"]];
                 commdity.how=[NSString stringWithFormat:@"%@",[commdity.Dict objectForKey:@"payAmount"]];
                NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
                [numberFormatter setPositiveFormat:@"###,##0.00;"];
                NSString *formattedNumberString = [numberFormatter stringFromNumber:[NSNumber numberWithDouble:GoldPrice.floatValue]];
                  [self jiazai:formattedNumberString];
                
        
            }else{
                [Global hideProgressHUDInternal:self.view];
                NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                // [Global showTextHud:requestResultStr view:self.view];
                [Global showTextHudSub:requestResultStr view:self.view];
            }
            
        }
        else
        {
            [Global hideProgressHUDInternal:self.view];
            
            [Global showTextHudSub:@"连接失败" view:self.view];
        }
        
    }];
    


}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (void)showAlertWait
{
    alt = [[UIAlertView alloc] initWithTitle:@"网络不稳定 ！" message:@"请确认网络" delegate:self cancelButtonTitle:nil otherButtonTitles: nil];
    [alt show];
    
    [self performSelector:@selector(hideAlert) withObject:nil afterDelay:1.0f];
    
}

- (void)showAlertMessage:(NSString *)msg
{
    alt = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:msg delegate:nil cancelButtonTitle:nil otherButtonTitles: nil];
    [alt show];
    
    [self performSelector:@selector(hideAlert) withObject:nil afterDelay:1.0f];
}
- (void)hideAlert
{
    if (alt != nil)
    {
        [alt dismissWithClickedButtonIndex:0 animated:YES];
        alt = nil;
    }
}
- (void)times{
    
    time = [[UIButton alloc]init];
    time.frame = CGRectMake(ScreenWidth-100,ScreenHeight*35/2200,30,16);
    [time setTitleColor:[UIColor clearColor] forState:UIControlStateNormal];
    [time setTitle:[NSString stringWithFormat:@"%d",10] forState:UIControlStateNormal];
    time.titleLabel.font = [UIFont boldSystemFontOfSize:16];
    [myscrollView addSubview:time];
    
    [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(countDownActions:) userInfo:time repeats:YES];
    
    
}
//自动更新
-(void)countDownActions:(NSTimer*)timer{
    
    time = timer.userInfo;
    
    if (!time.superview) {
        [timer invalidate];
        return;
    }
    int currentTime = [[time titleForState:UIControlStateNormal] intValue];
    [time setTitle:[NSString stringWithFormat:@"%d",--currentTime] forState:UIControlStateNormal];
    time.titleLabel.font = [UIFont systemFontOfSize:16];
    if (currentTime<1) {
        
        [time setTitle:[NSString stringWithFormat:@"%d",10] forState:UIControlStateNormal];
        [self times];
       [time removeFromSuperview];
        NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
        NSString* Token = [user objectForKey:@"tokenId"];
        NSMutableDictionary *params = [NSMutableDictionary new];
        [params setValue:Token forKey:@"tokenId"];
        [params setValue:commdity.gid forKey:@"gid"];
        NSLog(@"%@",params);
        
        [HttpRequest requestData:@"Business/Gathering/Detail" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
            if (isSuccess) {
                NSLog(@"－－%@",severDataDict.dataDict);
                if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                    [Global hideProgressHUDInternal:self.view];
        
                    
                    if ([[severDataDict.dataDict  objectForKey:@"status"] isEqualToString:@"N"]) {
                        
                    }if ( [[severDataDict.dataDict  objectForKey:@"status"] isEqualToString:@"Y"]) {
                        
                        [time removeFromSuperview];
                        
                        [timer invalidate];
                        
                            if ([commdity.sat isEqualToString:@"card"]) {
                                commdity.gengxin=@"";
                                [self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:2] animated:YES];

                            }
                        
                        if ([commdity.sat isEqualToString:@"fuwushouyin"]) {
                            commdity.tuichu=@"shouye";
                            ServiceListViewController*de = [[ServiceListViewController alloc] init];
                            
                            [self.navigationController pushViewController:de animated:YES];
                            
                        }
                        
                        if ([commdity.sat isEqualToString:@"fuwubushouyin"]) {
                            
                            commdity.tuichu=@"自动不用做";
                            [self.navigationController popViewControllerAnimated:YES];
                            
                        }
                        
                        if ([commdity.sat isEqualToString:@"shouyin"]) {
                            
                            commdity.tuichu=@"shouye";
                            orderListsViewController*de = [[orderListsViewController alloc] init];
                            
                            [self.navigationController pushViewController:de animated:YES];
                            
                        }
                        
                        
                        if ([commdity.sat isEqualToString:@"bushouyin"]) {
                            
                            commdity.tuichu=@"自动不用做";
                            [self.navigationController popViewControllerAnimated:YES];
                            
                            
                        }
                        
                        
                        
                        
                    }
                    
                }else{
                    
                    
                }
                
            }
            else
            {
                [Global hideProgressHUDInternal:self.view];
                NSLog(@"aaaaaaaa%@",severDataDict.dataDict);
                [timer invalidate];
                [Global showTextHudSub:@"连接失败" view:self.view];
            }
            
        }];
        
    }
   

}
-(void)jiazai: (NSString*)formattedNumberString{
    
    
    
    payAmount=[[UILabel alloc]initWithFrame:CGRectMake(0, orderNo.bottom, ScreenWidth-15,ScreenHeight-ScreenWidth-60-100)];
    payAmount.text=[NSString stringWithFormat:@"¥ %@", formattedNumberString];
    payAmount.textAlignment = NSTextAlignmentRight;
    payAmount.font=[UIFont boldSystemFontOfSize:daixao];
    payAmount.backgroundColor=[UIColor colorWithRed:14/255.0 green:23/255.0 blue:0/255.0 alpha:1.0];
    payAmount.textColor=[UIColor colorWithRed:225/255.0 green:238/255.0 blue:203/255.0 alpha:1.0];
    NSMutableAttributedString *AttributedStr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"¥ %@" ,formattedNumberString]];
    
    [AttributedStr addAttribute:NSFontAttributeName
     
                          value:[UIFont systemFontOfSize:30.0]
     
                          range:NSMakeRange(0, 1)];
    
    [AttributedStr addAttribute:NSForegroundColorAttributeName
     
                          value:[UIColor colorWithRed:225/255.0 green:238/255.0 blue:203/255.0 alpha:1.0]
     
                          range:NSMakeRange(0, 1)];
    
    
    payAmount.attributedText = AttributedStr;
    [self.view addSubview:payAmount];
    
    
    UILabel*bianView=[[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth-15, orderNo.bottom,15 ,ScreenHeight-ScreenWidth-60-100)];
    
    bianView.backgroundColor=[UIColor colorWithRed:14/255.0 green:23/255.0 blue:0/255.0 alpha:1.0];
    
    [self.view addSubview:bianView];
    shoukuanfangsi=[[UILabel alloc]initWithFrame:CGRectMake(0, payAmount.bottom, ScreenWidth, 355)];
    shoukuanfangsi.text=@"请选择支付方式";
    shoukuanfangsi.textColor=zhonghuiColor;
    shoukuanfangsi.font=[UIFont systemFontOfSize:16];
    shoukuanfangsi.textAlignment=NSTextAlignmentCenter;
    [self.view addSubview:shoukuanfangsi];
    
    UIButton*btn=[[UIButton alloc]initWithFrame:CGRectMake(0, ScreenHeight-60, ScreenWidth/4, 60)];
    btn.backgroundColor=[UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0];
    [btn addTarget:self action:@selector(xianjinlabelbtn:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];
    xianjinlabelbtn=[[UIButton alloc]initWithFrame:CGRectMake(0, ScreenHeight-20, ScreenWidth/4, 13)];
    [xianjinlabelbtn  setTitle:@"现金" forState:UIControlStateNormal];
    [xianjinlabelbtn addTarget:self action:@selector(xianjinlabelbtn:) forControlEvents:UIControlEventTouchUpInside];
    [xianjinlabelbtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    xianjinlabelbtn.titleLabel .font=[UIFont systemFontOfSize:13];
    [self.view addSubview:xianjinlabelbtn];
    
    UIButton*imagebtn=[[UIButton alloc]initWithFrame:CGRectMake(0, ScreenHeight-60, ScreenWidth/4, 40)];
    [imagebtn addTarget:self action:@selector(xianjinlabelbtn:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:imagebtn];
    UIImageView*imageview=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 45, 45)];
    imageview.image=[UIImage imageNamed:@"xianjins"];
    imageview.center=imagebtn.center;
    [self.view addSubview:imageview];
    
    
    
    UIButton*shuakabtn=[[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth/4, ScreenHeight-60, ScreenWidth/4, 60)];
    shuakabtn.backgroundColor=[UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0];
    [shuakabtn addTarget:self action:@selector(shuakabtnlabelbtn:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:shuakabtn];
    shuakabtnlabelbtn=[[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth/4, ScreenHeight-20, ScreenWidth/4, 13)];
    [shuakabtnlabelbtn  setTitle:@"刷卡" forState:UIControlStateNormal];
    [shuakabtnlabelbtn addTarget:self action:@selector(shuakabtnlabelbtn:) forControlEvents:UIControlEventTouchUpInside];
    [shuakabtnlabelbtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    shuakabtnlabelbtn.titleLabel .font=[UIFont systemFontOfSize:13];
    [self.view addSubview:shuakabtnlabelbtn];
    UIButton*shuakabtnlabelbtnimagebtn=[[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth/4, ScreenHeight-60, ScreenWidth/4, 40)];
    [shuakabtnlabelbtnimagebtn addTarget:self action:@selector(shuakabtnlabelbtn:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:shuakabtnlabelbtnimagebtn];
    UIImageView*shuakabtnlabelbtnimagebtnimageview=[[UIImageView alloc]initWithFrame:CGRectMake(ScreenWidth/4, 0, 45, 45)];
    shuakabtnlabelbtnimagebtnimageview.image=[UIImage imageNamed:@"shuakas"];
    shuakabtnlabelbtnimagebtnimageview.center=shuakabtnlabelbtnimagebtn.center;
    [self.view addSubview:shuakabtnlabelbtnimagebtnimageview];
    
    
    
    
    UIButton*zhifubaobtn=[[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth/4*2, ScreenHeight-60, ScreenWidth/4, 60)];
    zhifubaobtn.backgroundColor=[UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0];
    [zhifubaobtn addTarget:self action:@selector(zhifubaobtn:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:zhifubaobtn];
    zhifulabelbaobtn=[[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth/4*2, ScreenHeight-20, ScreenWidth/4, 13)];
    [zhifulabelbaobtn  setTitle:@"支付宝" forState:UIControlStateNormal];
    [zhifulabelbaobtn addTarget:self action:@selector(zhifubaobtn:) forControlEvents:UIControlEventTouchUpInside];
    [zhifulabelbaobtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    zhifulabelbaobtn.titleLabel .font=[UIFont systemFontOfSize:13];
    [self.view addSubview:zhifulabelbaobtn];
    UIButton*zhifubaobtn1imagebtn=[[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth/4*2, ScreenHeight-60, ScreenWidth/4, 40)];
    [zhifubaobtn1imagebtn addTarget:self action:@selector(zhifubaobtn:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:zhifubaobtn1imagebtn];
    UIImageView*zhifubaobtnimageview=[[UIImageView alloc]initWithFrame:CGRectMake(ScreenWidth/4*2, 0, 45, 45)];
    zhifubaobtnimageview.image=[UIImage imageNamed:@"zhifubaos"];
    zhifubaobtnimageview.center=zhifubaobtn1imagebtn.center;
    [self.view addSubview:zhifubaobtnimageview];
    
    
    
    UIButton*weixinbtn=[[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth/4*3, ScreenHeight-60, ScreenWidth/4, 60)];
    weixinbtn.backgroundColor=[UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0];
    [weixinbtn addTarget:self action:@selector(weixinbtn:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:weixinbtn];
    weixinbtnlabelbtn=[[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth/4*3, ScreenHeight-20, ScreenWidth/4, 13)];
    [weixinbtnlabelbtn  setTitle:@"微信" forState:UIControlStateNormal];
    [weixinbtnlabelbtn addTarget:self action:@selector(weixinbtn:) forControlEvents:UIControlEventTouchUpInside];
    [weixinbtnlabelbtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    weixinbtnlabelbtn.titleLabel .font=[UIFont systemFontOfSize:13];
    [self.view addSubview:weixinbtnlabelbtn];
    
    UIButton*weixinbtnlabelbtnimagebtn=[[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth/4*3, ScreenHeight-60, ScreenWidth/4, 40)];
    [weixinbtnlabelbtnimagebtn addTarget:self action:@selector(weixinbtn:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:weixinbtnlabelbtnimagebtn];
    UIImageView*weixinbtnlabelbtnimagebtnimageview=[[UIImageView alloc]initWithFrame:CGRectMake(ScreenWidth/4*3, 0, 45, 45)];
    weixinbtnlabelbtnimagebtnimageview.image=[UIImage imageNamed:@"weixins"];
    weixinbtnlabelbtnimagebtnimageview.center=weixinbtnlabelbtnimagebtn.center;
    [self.view addSubview:weixinbtnlabelbtnimagebtnimageview];
    
    
    
}

-(void)closeKeyBoad
{
    
    shoukuanfangsi.textColor=zhonghuiColor;
    [myscrollView removeFromSuperview];
    [ditu removeFromSuperview];
    [chaimageview removeFromSuperview];
    [time removeFromSuperview];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
